package com.example.service;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

/**
 * 你还
 */
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        run();
    }
//子线程更新数据，首先创建 hander ，用于接收消息
//然后创建新线程，用 hander 发送message数据
    private Handler handler = new Handler(){
    @Override
    public void handleMessage(@NonNull Message msg) {
        Log.d(TAG, "handleMessage: ");
    }
};
    public void run(){
        final Message message = new Message();
        new Thread(new Runnable() {
            @Override
            public void run() {
                message.what =10;
                handler.sendMessage(message);
            }
        }).start();
    }
}
